package com.likuicat.picture_ddd.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.likuicat.picture_ddd.infrastructure.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.likuicat.picture_ddd.interfaces.dto.picture.*;
import com.likuicat.picture_ddd.domain.picture.entity.Picture;
import com.likuicat.picture_ddd.domain.user.entity.User;
import com.likuicat.picture_ddd.interfaces.vo.picture.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author fc3379757631
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-05-06 16:38:48
*/
public interface PictureApplicationService extends IService<Picture> {

    /**
     * 上传图片
     * @param inputSource
     * @param pictureUpdateRequest
     * @param loginUser
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadRequest pictureUpdateRequest, User loginUser);

    /**
     * 转化为QueryWrapper
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 获取单个图片封装
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 分页获取图片封装
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage,HttpServletRequest request);

    /**
     * 校验图片规则
     * @param picture
     */
    void validPicture(Picture picture);

    /**
     * 图片审核
     *
     * @param pictureReviewRequest
     * @param loginUser
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 设置审核状态：管理员自动过审并且填充审核参数；用户上传或编辑图片时，图片的状态会被重置为“待审核”。
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取和创建图片
     *
     * @param pictureUploadByBatchRequest
     * @param loginUser
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchRequest pictureUploadByBatchRequest,
            User loginUser
    );

    /**
     * 清理图片地址
     * @param oldPicture
     */
    void clearPictureUrl(Picture oldPicture);

    /**
     * 校验图片权限
     * @param picture
     * @param loginUser
     */
    void checkPictureAuth(Picture picture, User loginUser);

    /**
     * 删除图片
     * @param pictureId
     * @param loginUser
     */
    void deletePicture(long pictureId, User loginUser);

    /**
     * 编辑图片
     * @param picture
     * @param loginUser
     */
    void editPicture(Picture picture, User loginUser);

    /**
     * 按颜色查询图片
     * @param spaceId
     * @param picColor
     * @param loginUser
     * @return
     */
    List<PictureVO> searchPictureByColor(Long  spaceId,String picColor,User loginUser);


    /**
     * 批量修改图片
     * @param pictureEditByBatchRequest
     * @param loginUser
     */
    void pictureEditByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * AI扩图功能
     * @param createPictureOutPaintingTaskRequest
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse creatPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}
